<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>川邮学员管理系统登录</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }
        #main {
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            width: 300px;
        }
        form {
            display: flex;
            flex-direction: column;
        }
        form > div {
            margin-top: 10px;
        }
        .form-label {
            margin-bottom: 5px;
        }
        .form-input {
            padding: 8px;
            width: 100%;
            box-sizing: border-box;
        }
        .form-button {
            padding: 10px 20px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            margin-top: 10px;
        }
        .form-button:hover {
            background-color: #45a049;
        }
        .error-message {
            color: red;
            margin-top: 5px;
        }
        .welcome-message {
            color: aliceblue;
            text-align: center;
        }
        .hr-style {
            width: 90%;
            margin: 10px 0;
        }
        .captcha-container {
            display: flex;
            align-items: center;
        }
        .captcha-label {
            margin-right: 10px;
        }
        .captcha-input {
            width: 30%;
        }
        .captcha-button {
            margin-left: 10px;
        }
    </style>
</head>
<body>
    <div id="main">
        <form id="loginForm">
            <h1 class="welcome-message">欢迎使用川邮学员管理系统</h1>
            <hr class="hr-style">
            <div>
                <label for="nameinput" class="form-label">用户名:</label>
                <input type="text" id="nameinput" class="form-input">
                <div id="nameError" class="error-message"></div>
            </div>
            <div>
                <label for="pswdinput" class="form-label">密&nbsp;&nbsp;&nbsp;&nbsp;码:</label>
                <input type="password" id="pswdinput" class="form-input">
                <div id="pswdError" class="error-message"></div>
            </div>
            <div class="captcha-container">
                <label for="yzminput" class="captcha-label">验证码:</label>
                <input type="text" id="yzminput" class="captcha-input form-input">
                <input type="button" value="获取验证码" id="getCaptchaButton" class="captcha-button form-button">
            </div>
            <div>
                <input type="button" value="新用户注册" id="registerButton" class="form-button">
                <input type="button" value="登录" id="loginButton" class="form-button">
            </div>
        </form>
    </div>

    <script>
        document.getElementById('loginButton').addEventListener('click', login);

        function login() {
            const nameInput = document.getElementById("nameinput");
            const pswdInput = document.getElementById("pswdinput");
            const nameError = document.getElementById("nameError");
            const pswdError = document.getElementById("pswdError");

            // Reset error messages
            nameError.textContent = '';
            pswdError.textContent = '';

            // Validate username
            if (nameInput.value.length < 2) {
                nameError.textContent = "你的用户名太短了";
                return;
            }
            if (nameInput.value.includes("犯罪")) {
                nameError.textContent = "你的用户名太奇葩了";
                return;
            }
            if (nameInput.value.startsWith("山本")) {
                nameError.textContent = "我们的系统只给cn学生用";
                return;
            }
            if (nameInput.value.endsWith("太郎")) {
                nameInput.value = "大朗";
                nameError.textContent = "中国人的姓名不以太郎结尾";
                return;
            }

            // Validate password
            if (pswdInput.value.length < 6) {
                pswdError.textContent = "你的密码不符合要求";
                return;
            }

            // If all validations pass
            alert("登录成功！");
        }
    </script>
</body>
</html>